<?php
namespace app\appclass\controller;
use app\AdminRest;

use app\appclass\model\ClassCate;
use app\appclass\model\ClassDate;
use app\appclass\model\ClassLable;
use app\appclass\model\ClassRecord;
use app\appclass\model\ClassRoom;
use app\appclass\model\Lable;
use app\shop\model\IndexCompany;
use think\App;




class AdminConfig extends AdminRest
{

    protected $cate_model;

    protected $lable_model;

    protected $room_model;

    public function __construct(App $app) {

        parent::__construct($app);

        $this->cate_model  = new ClassCate();

        $this->lable_model = new Lable();

        $this->room_model  = new ClassRoom();

    }


    /**
     * @author chenniang
     * @DataTime: 2021-05-12 15:48
     * @功能说明:门店列表
     */
    public function storeList(){

        $company_model = new IndexCompany();

        $dis = [

            'uniacid' => $this->_uniacid,

            'pid'    => 0
        ];

        $data = $company_model->where($dis)->select()->toArray();

        return $this->success($data);
    }


    /**
     * @author chenniang
     * @DataTime: 2021-05-11 16:26
     * @功能说明:教室列表
     */
    public function roomList(){

        $input = $this->_param;

        $dis = [

            'uniacid' => $this->_uniacid,

            'store_id'=> $input['store_id']
        ];

        $data = $this->room_model->dataList($dis,$input['limit']);

        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2021-05-11 16:29
     * @功能说明:教室详情
     */
    public function roomInfo(){

        $input = $this->_param;

        $dis = [

            'id' => $input['id']
        ];

        $data = $this->room_model->dataInfo($dis);

        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2021-05-11 16:30
     * @功能说明:教室编辑
     */
    public function roomUpdate(){

        $input = $this->_input;

        $dis = [

            'id' => $input['id']
        ];

        $res = $this->room_model->dataUpdate($dis,$input);

        return $this->success($res);

    }


    /**
     * @author chenniang
     * @DataTime: 2021-05-11 16:31
     * @功能说明:添加教室
     */
    public function roomAdd(){

        $input = $this->_input;

        $input['uniacid'] = $this->_uniacid;

        $res = $this->room_model->dataAdd($input);

        return $this->success($res);

    }


    /**
     * @author chenniang
     * @DataTime: 2021-05-11 16:32
     * @功能说明:标签列表
     */
    public function lableList(){

        $input = $this->_param;

        $dis = [

            'uniacid' => $this->_uniacid,

            'pid'     => 0
        ];

        $data = $this->lable_model->dataList($dis,$input['limit']);

        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2021-05-12 18:02
     * @功能说明:
     */
    public function lableSelect(){


        $input = $this->_param;

        $dis = [

            'uniacid' => $this->_uniacid,

            'pid'     => 0
        ];

        $data = $this->lable_model->where($dis)->where('status','>',-1)->select()->toArray();

        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2021-05-11 17:17
     * @功能说明:标签详情
     */
    public function lableInfo(){

        $input = $this->_param;

        $dis = [

            'id' => $input['id']
        ];

        $data = $this->lable_model->dataInfo($dis);

        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2021-05-11 17:21
     * @功能说明:标签编辑
     */
    public function lableUpdate(){

        $input = $this->_input;

        $dis = [

            'id' => $input['id']

        ];

        $res = $this->lable_model->dataUpdate($dis,$input);

        if(isset($input['status'])){

            $where[] = ['pid','=',$input['id']];

            $where[] = ['status','>',-1];

            $res = $this->lable_model->dataUpdate($where,['status'=>$input['status']]);
        }

        return $this->success($res);

    }


    /**
     * @author chenniang
     * @DataTime: 2021-05-11 17:41
     * @功能说明:添加
     */
    public function lableAdd(){

        $input = $this->_input;

        $input['uniacid'] = $this->_uniacid;

        $res = $this->lable_model->dataAdd($input);

        return $this->success($res);


    }




    /**
     * @author chenniang
     * @DataTime: 2021-05-11 17:29
     * @功能说明:分类列表
     */
    public function cateList(){

        $input = $this->_param;

        $dis = [

            'uniacid' => $this->_uniacid,

            'store_id'=> $input['store_id'],

        ];

        $data = $this->cate_model->dataList($dis,$input['limit']);

        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2021-05-11 17:39
     * @功能说明:添加分类
     */
    public function cateAdd(){

        $input = $this->_input;

        $input['uniacid'] = $this->_uniacid;

        $res = $this->cate_model->dataAdd($input);

        return $this->success($res);

    }


    /**
     * @author chenniang
     * @DataTime: 2021-05-11 17:43
     * @功能说明:分类详情
     */
    public function cateInfo(){

        $input = $this->_param;

        $dis = [

            'id' => $input['id']
        ];

        $data = $this->cate_model->dataInfo($dis);

        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2021-05-11 17:43
     * @功能说明:编辑分类
     */
    public function cateUpdate(){

        $input = $this->_input;

        $dis = [

            'id' => $input['id']
        ];

        if(isset($input['status'])&&in_array($input['status'],[-1,0])){

            $this->cate_model->check($input['id']);
        }

        $res = $this->cate_model->dataUpdate($dis,$input);

        return $this->success($res);

    }









}
